<?php
	// Setup globals
	// @todo: Get these out of template
	global $wp_query;

	// Setup image width and height variables
	// @todo: Investigate if these are still needed here
	$image_width  = get_option( 'single_view_image_width' );
	$image_height = get_option( 'single_view_image_height' );
?>
<div>
	<div class="breadcrumbs"><?php wpsc_output_breadcrumbs(array('show_home_page'=>false,'show_products_page'=>false)); ?></div>

	<?php
			/**
			 * Start the product loop here.
			 * This is single products view, so there should be only one
			 */

		while ( wpsc_have_products() ) : wpsc_the_product(); ?>
		<div class="details_holder clear">
			<div class="details_column1 left">
				<div class="imagecol">
					<?php if ( wpsc_the_product_thumbnail() ) : ?>
							<a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo esc_url( wpsc_the_product_image() ); ?>">
								<?php 
									$size = array(425,375);
									$attr = array('class'=>'product_image','id'=>'product_image_'.wpsc_the_product_id(),'alt'=> wpsc_the_product_title() );
									the_post_thumbnail($size,$attr); 
								?>
							</a>
							<?php
							if ( function_exists( 'gold_shpcrt_display_gallery' ) )
								echo gold_shpcrt_display_gallery( wpsc_the_product_id() );
							?>
					<?php else: ?>
								<a href="<?php echo esc_url( wpsc_the_product_permalink() ); ?>">
								<img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />
								</a>
					<?php endif; ?>
				</div><!--close imagecol-->
			</div>
			
			<div class="details_column2 right">
				<div class="details_title"><?php echo wpsc_the_product_title(); ?> </div>
				
				<div class="details_price clear">
					<form class="product_form" enctype="multipart/form-data" action="<?php echo esc_url( wpsc_this_page_url() ); ?>" method="post" name="1" id="product_<?php echo wpsc_the_product_id(); ?>">
					<?php do_action ( 'wpsc_product_form_fields_begin' ); ?>
					<div class="left">
						<div class="wpsc_product_price">
							<?php if(wpsc_show_stock_availability()): ?>
								<?php if(wpsc_product_has_stock()) : ?>
									<div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
								<?php else: ?>
									<div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
								<?php endif; ?>
							<?php endif; ?>
							<?php if(wpsc_product_is_donation()) : ?>
								<label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>: </label>
								<input type="text" id="donation_price_<?php echo wpsc_the_product_id(); ?>" name="donation_price" value="<?php echo wpsc_calculate_price(wpsc_the_product_id()); ?>" size="6" />
							<?php else : ?>
								<div class="price bold"><?php echo wpsc_product_normal_price(); ?></div>
								 <!-- multi currency code -->
								<?php if(wpsc_product_has_multicurrency()) : ?>
									<div class="price bold"><?php echo wpsc_display_product_multicurrency(); ?></div>
								<?php endif; ?>
								<?php if(wpsc_show_pnp()) : ?>
									<div class="price bold"><p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p></div>
								<?php endif; ?>
							<?php endif; ?>
						</div><!--close wpsc_product_price-->
					</div>
					<div class="detail_cart_holder group right">
						 <!--<a href="#" class="details_cart"><img src="<?php bloginfo( 'template_url' ); ?>/images/cart_icon.png" /> Add To Cart </a>-->
						<?php
						/**
						 * Quantity options - MUST be enabled in Admin Settings
						 */
						?>
						<?php if(wpsc_product_has_stock()) : ?>
							<?php if(wpsc_has_multi_adding()): ?>
								<div class="left" style="padding-top:11px;">Enter Quantity :</div>
								<div class="wpsc_quantity_update left">
								<input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="1" class="details_qty"/>
								<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
								<input type="hidden" name="wpsc_update_quantity" value="true" />
								</div><!--close wpsc_quantity_update-->
							<?php endif ;?>
						<?php endif ;?>
						<input type="hidden" value="add_to_cart" name="wpsc_ajax_action" />
						<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id" />
						<?php
						/**
						 * Cart Options
						 */
						?>
						<?php if(wpsc_product_has_stock()) : ?>
							<?php if((get_option('hide_addtocart_button') == 0) &&  (get_option('addtocart_or_buynow') !='1')) : ?>
								<?php if(wpsc_product_has_stock()) : ?>
									<div class="wpsc_buy_button_container left">
											<?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
											<?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
											<input class="wpsc_buy_button" type="submit" value="<?php echo wpsc_product_external_link_text( wpsc_the_product_id(), __( 'Buy Now', 'wpsc' ) ); ?>" onclick="return gotoexternallink('<?php echo esc_url( $action ); ?>', '<?php echo wpsc_product_external_link_target( wpsc_the_product_id() ); ?>')">
											<?php else: ?>
										<input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
											<?php endif; ?>
										<div class="wpsc_loading_animation">
											<img title="Loading" alt="Loading" src="<?php echo wpsc_loading_animation_url(); ?>" />
											<?php _e('Updating cart...', 'wpsc'); ?>
										</div><!--close wpsc_loading_animation-->
									</div><!--close wpsc_buy_button_container-->
								<?php else : ?>
									<p class="soldout"><?php _e('This product has sold out.', 'wpsc'); ?></p>
								<?php endif ; ?>
							<?php endif ; ?>
						<?php endif ; ?>
					</div>
					<?php do_action ( 'wpsc_product_form_fields_end' ); ?>
					</form>
				</div>
				
				<div class="details_links" id="single-tabs">
					<ul>
						<li><a href="#tab1"><img src="<?php bloginfo( 'template_url' ); ?>/images/icon_disc.png" alt="disc" align="absmiddle" /> Video</a></li>
						<li><a href="#tab2"><img src="<?php bloginfo( 'template_url' ); ?>/images/icon_desc.png" alt="disc" align="absmiddle" /> Description</a></li>
						<li>
							<a href="#tab3"><img src="<?php bloginfo( 'template_url' ); ?>/images/icon_review.png" alt="disc" align="absmiddle" /> 
								<?php $count = cc_get_product_review( wpsc_the_product_id() ); ?>
								<?php echo count( $count );?> Review
							</a>
						</li>
					</ul>
					<div class="video" id="tab1">
						<div style="min-height:400px;">
							<?php cc_get_product_video( wpsc_the_product_id(),530,390 );?> 
						</div>
					</div>
					<div class="details_desc" id="tab2">
						<?php the_content(); ?>
					</div>
					<div class="reviews" id="tab3">
						<div id="reviewtab">
							<?php cc_print_review_product( wpsc_the_product_id() ); ?>
						</div>
						<div class="jquery-cycle-controls">
							<a href="#"><span id="prev">Prev</span></a> 
							<a href="#"><span id="next">Next</span></a>
						</div>
					</div>
				</div>

				</form>
				<div class="details_share group">
					<div class="right"><?php echo st_makeEntries(); ?></div>
					<div class="right" style="padding-top:5px; padding-right:10px;">Share this Product with your friends </div>
				</div>
			</div>
			
			<form onsubmit="submitform(this);return false;" action="<?php echo esc_url( wpsc_this_page_url() ); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_extra_<?php echo wpsc_the_product_id(); ?>">
				<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="prodid"/>
				<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="item"/>
			</form>
			
		</div><!-- details_holder -->
		
						

	<?php endwhile;
		
		do_action( 'wpsc_theme_footer' ); ?>
		<div class="featured_products">
			<div class="featured_products_title">Other products you might also be interested in</div>
			<div class="featured_products_content">
				<?php require('wpsc-random_product.php');?>
			</div><!-- end featured banner -->
			<!--<div class="shadow"></div>-->
		</div>
	</div>
</div>
